/**
 * @FilePath     : /src/lgmg_robots/agv_navigation/agv_navigate/include/agvNavigate/opInclude/operation_cross_floor.h
 * @Description  : 跨楼层操作类的定义，继承自Operation类，包含初始化、开始、结束和工作方法的声明。 
 *                 该类用于处理AGV在跨楼层时的定位和跳转操作。  
 * @Author       : xiujun.yang
 * @Version      : 1.0.0
 * @LastEditors  : haibo haibo.yang@lgmgim.cn
 * @LastEditTime : 2024-12-19 16:34:18
 * @Copyright (c) 2024 by 临工智能信息科技有限公司, All Rights Reserved. 
**/
#pragma once 
#include "operation.h"
#include <agv_msgs/msg/init_pose.hpp>

// 跨楼层动作类型名称
constexpr const char* CROSS_FLOOR_ACTION_TYPE = "initPosition";
//////////////////////////////////////////////////////////////////////////////
//   The interface of class "Operation".
class OperationCrossFloor : public Operation
{
 public:
    explicit OperationCrossFloor(const agv_msgs::msg::Action& action);

    // The destructor
    virtual ~OperationCrossFloor();

    // Initialize the related data
    virtual bool Init() override;

    // Ready to start new op
    virtual bool ReadyStart() override;

    // Defines how to start the operation
    virtual bool StartAction() override;

    // Defines how to end the operation
    virtual bool EndAction() override;

    // Defines how to do the operation
    virtual bool Work() override;

 private:
    void InitRos();

    // 调度下发参数是否完整
    bool ValidParam();

    // 发布跳转
    void AdvertiseJump(bool active);

    // 定位数据跳转完成
    bool JumpFinish();

    // 正常结束过程
    bool WorkFinish();

    // 设置当前楼层
    void SetCurFloor();

    // 屏蔽脱轨事件(跨楼层时，屏蔽脱轨)
    void MutePathLostEvent(bool mute);

    // 位姿跳转
    std::shared_ptr<rclcpp::Publisher<agv_msgs::msg::InitPose>> jump_pub_;
    // 位姿跳转消息格式
    agv_msgs::msg::InitPose msg_;

    struct InitPositionParam {
        std::pair<std::string, float> x;
        std::pair<std::string, float> y;
        std::pair<std::string, float> theta;
        std::pair<std::string, int> target_node_id;
        std::pair<std::string, std::string> zone_tag;
        InitPositionParam() {
            x = {"x", 0.0};
            y = {"y", 0.0};
            theta = {"theta", 0.0};
            target_node_id = {"targetNodeId", 0};
            zone_tag = {"zoneTag", "unkown"};
        }
    } pose_;
};
